#!/bin/sh
set -eu
    
usage () {
    echo "usage: git recent-branches [-h]" >&2
    echo >&2
    echo "Shows a list of local branches, ordered by their date (most recent one first)." >&2
    echo >&2
    echo "Options:" >&2
    echo "-h    Show this help" >&2
}

while getopts h flag; do
    case "$flag" in
        h) usage; exit 2;;
    esac
done

git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short)'
